package com.hjf.ditubiaozhu.base;

import java.util.List;

public class Result<T> {

    public static ErrorCodeMapper defaultCode = new ErrorCodeMapper(0, "");
    //用户相关
    public static ErrorCodeMapper unlogin = new ErrorCodeMapper(1001, "<a href=/saolou/auth/login>您还未登录,请登录</a>");
    public static ErrorCodeMapper outDate = new ErrorCodeMapper(1002, "<a href=/saolou/auth/login>账号过期,请从新登录</a>");
    public static ErrorCodeMapper denied = new ErrorCodeMapper(1003, "没有访问权限,请联系管理员");
    public static ErrorCodeMapper cookieParseErr = new ErrorCodeMapper(1004, "cookie解析错误");
    //结果集判断
    public static ErrorCodeMapper notDate = new ErrorCodeMapper(2001, "没有数据");
    //登录
    public static ErrorCodeMapper loginError = new ErrorCodeMapper(3001, "账号密码错误");

    private int code;
    private String msg;
    private String type;
    private int userId;
    private int size;

    private List<T> beans;

    public Result() {
        setCodeMapper(defaultCode);
    }

    public void setCodeMapper(ErrorCodeMapper errorCodeMapper) {
        code = errorCodeMapper.code;
        msg = errorCodeMapper.msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }


    public List<T> getBeans() {
        return beans;
    }

    public void setBeans(List<T> beans) {
        this.beans = beans;
        size = beans.size();

    }
}
